package com.pokerpro.support;

import java.awt.Color;
import java.awt.Point;
import java.awt.Robot;
import java.awt.event.InputEvent;

public class BaseElement {

	private Robot robot;

	public BaseElement(Robot pRobot) {
		try {
			robot = pRobot;
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public void mouseMove(Point pPoint) {
		robot.mouseMove(pPoint.x, pPoint.y);
	}

	/**
	 * 
	 * 
	 * @param pClickDouble
	 * @param pPoint
	 * @param pDelay
	 *            negativ value: waiting ms before click, positiv value waiting
	 *            after click
	 */
	public void mouseMoveAndClick(int howOften, Point pPoint) {
		mouseMove(pPoint);
		for (int i = 0; i < howOften; i++) {
			mousePressLeft();
		}

	}

	public void mousePressLeft() {
		robot.mousePress(InputEvent.BUTTON1_MASK);
		robot.mouseRelease(InputEvent.BUTTON1_MASK);

	}

	public void mousePressRight() {
		robot.mousePress(InputEvent.BUTTON2_MASK);
		robot.mouseRelease(InputEvent.BUTTON2_MASK);
	}

	public Color getPixelCol(Point pPoint) {
		return robot.getPixelColor(pPoint.x, pPoint.y);
	}

	public void delay(int pTime) {
		robot.delay(pTime);
	}

	public Robot getRobot() {
		return robot;
	}
}
